<script>
import indexJs from '@/jsInAppVue/index.js'
import i18nJs from "@/commonJs/i18n";
import userStore from "@/store/modules/user";

export default {
  created() {

  },
  onLaunch(e) {
    // 清理前缀是"requestNumber:"的缓存
    indexJs.clearRequestNumberCache();

    // 获取系统字典
    i18nJs.getDictI18nMapOfAppFront();

    // this.requestUserInfoSelf();

    if(e.query.inviteCode){
      uni.setStorageSync('inviteCode',e.query.inviteCode);
    }

  },
  onShow: function () {
  },
  onHide: function () {
  },
  methods: {
    // 获取用户信息 system-user-web/user/getSelf
    requestUserInfoSelf() {
      this.$request({
        url: '/system-user-web/user/getSelf',
        method: 'POST',
        stateSuccess: res => {
          userStore.setSelfInfo(res.data);
        },
        stateFail: res => {
          if(res.stateCode == 'notLogin'){
            userStore.setSelfInfo(null);
            // 获取当前页面路径
            let pages = getCurrentPages();
            let currentPage = pages[pages.length - 1];
            if(currentPage.route != 'pages/login/login') {
              uni.navigateTo({
                url: '/pages/login/login'
              });
            }
          }
        }
      })
    },
  }
}
</script>

<style>
/*每个页面公共css */
</style>
